#******************************************************************
#
# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Import('env')
import os
import os.path
target_os = env.get('TARGET_OS')
target_arch = env.get('TARGET_ARCH')
samples_env = env.Clone()

######################################################################
# Build flags
######################################################################
samples_env.PrependUnique(CPPPATH=[
    '#/resource/oc_logger/include',
    '#/resource/csdk/logger/include',
    '#/resource/csdk/include',
    '#/resource/csdk/stack/include',
    '#/plugins/include',
])

samples_env.AppendUnique(
    CXXFLAGS=['-std=c++0x', '-Wall', '-Wextra'])

if target_os in ['darwin', 'ios']:
    samples_env.PrependUnique(LIBS=[
        'm',
        'octbstack',
        'ocsrm',
        'connectivity_abstraction',
        'coap',
    ])
else:
    samples_env.PrependUnique(LIBS=[
        'm',
        'octbstack',
        'ocsrm',
        'connectivity_abstraction',
        'coap',
        'plugin_interface',
    ])
    samples_env.AppendUnique(LIBS=['rt'])
    if target_arch in ['x86_64', 'arm64']:
        samples_env.AppendUnique(CPPFLAGS=['-Llib64'])
    else:
        samples_env.AppendUnique(CPPFLAGS=['-Llib'])
    samples_env.AppendUnique(LIBS=['pthread'])

if env.get('SECURED') == '1':
    samples_env.AppendUnique(LIBS=['mbedtls', 'mbedx509', 'mbedcrypto'])

######################################################################
# Source files and Targets
######################################################################
iotivityandzigbeeserver = samples_env.Program('iotivityandzigbeeserver',
                                              ['IotivityandZigbeeServer.c'])
iotivityandzigbeeclient = samples_env.Program('iotivityandzigbeeclient',
                                              ['IotivityandZigbeeClient.c'])

list_of_samples = [iotivityandzigbeeserver, iotivityandzigbeeclient]

Alias("samples", list_of_samples)

env.AppendTarget('samples')
samples_env.UserInstallTargetExtra(list_of_samples)
